<template>
<!-- 导航 -->
  <nav>
    <div class="banxin tanxin nav_in">
      <img src="../assets/images/indexLogo.png" alt="" />
      <ul class="tanxin">
        <li :class="{'active': $route.path === '/home' ||  $route.path === '/'}" @click="$router.push('/')">首页</li>
        <li :class="{'active': $route.path === '/allgoods'}" @click="$router.push('/allgoods')">全部商品</li>
        <li :class="{'active': $route.path === '/personalcenter'}" @click="$router.push('/personalcenter')">个人中心</li>
        <li :class="{'active': $route.path === '/myorder'}" @click="$router.push('/myorder')">我的订单</li>
        <li :class="{'active': $route.path === '/welfare'}" @click="$router.push('/welfare')">专属福利</li>
      </ul>
      <div class="search tanxin">
        <input type="text" placeholder="搜索全部商品" v-model="value" @keyup.enter="keyup"/>
        <div class="btn">
          <img src="../assets/images/search.png" alt="" />
        </div>
      </div>
    </div>
  </nav>
</template>

<script>
export default {
  data() {
    return {
      // 搜索框的值
      value:''
    };
  },
  methods:{
    keyup(){
       // 按回车跳转到全部商品页面并在路由中携带你输入的参数
      this.$router.push(`/allgoods?keyword=${this.value}`)
    }
  }
};
</script>
 
<style lang = "less" scoped>
@import "../assets/base.less";
nav {
  background-color: #fff;
  .nav_in {
    align-items: center;
    height: 100px;
    ul {
      width: 500px;
      cursor: pointer;
      li {
        font-size: 16px;
        font-family: SourceHanSansSC;
        font-weight: 500;
        color: @black;
        &.active {
          color: @blue;
          font-weight: bold;
        }
      }
    }
    .search {
      width: 264px;
      height: 40px;
      input {
        width: 214px;
        height: 40px;
        border: 1px solid #dedede;
        border-radius: 20px 0px 0px 20px;
        border-right: 0;
        text-indent: 1em;
        outline: none;
      }
      .btn {
        width: 50px;
        height: 44px;
        background: @blue;
        border-radius: 0px 20px 20px 0px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
}
</style>